package cn.donting.myapplication_java.slice;

import cn.donting.jme.ohos.renderer.OhosGL;
import cn.donting.jme.ohos.system.JmeOhosSystem;
import cn.donting.jme.ohos.system.OGLESContext;
import cn.donting.myapplication_java.JmeApp;
import cn.donting.myapplication_java.ResourceTable;
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystem;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.components.surfaceprovider.SurfaceProvider;
import ohos.agp.utils.Color;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbilitySlice extends AbilitySlice {
    static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00201, "MY_TAG");

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 声明布局
        DependentLayout myLayout = new DependentLayout(this);
      try {
          JmeSystem.setSystemDelegate(new JmeOhosSystem());
          JmeApp jmeApp = new JmeApp();
          jmeApp.start(false);
          OGLESContext context = (OGLESContext) jmeApp.getContext();
          SurfaceProvider surfaceProvider = context.creatGLSurfaceProvider(this);

          myLayout.addComponent(surfaceProvider);
      }catch (Exception ex){
          ex.printStackTrace();
          HiLog.info(label,ex.getMessage());
      }
        super.setUIContent(myLayout);


    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
